﻿using UnityEngine;
using System.Collections;

/*
 * 选择器，用于选定技能/普通攻击的可攻击范围
 * 一般来说是矩形，也可是好其它图形
 */ 

public class Picker : MonoBehaviour {

	public BoxCollider boxColli;
	public Soldier caster;

	// Use this for initialization
	void Start () {

	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	void OnTriggerEnter(Collider colli) {

		// start attack
		if (colli.gameObject.tag == "BodyParty")
		{
			Debug.Log("catch sight of enemy:" + colli.gameObject.GetComponent<Body>().mainSquare.gameObject.name + " , " + caster.rootObj.name + " do normal attack");

			caster.DoAttack(true);
		}
	}

	void OnTriggerExit(Collider colli) {

		// stop attack
		if (colli.gameObject.tag == "BodyParty")
		{
			Debug.Log("leave sight of enemy:" + colli.gameObject.GetComponent<Body>().mainSquare.gameObject.name + " , " + caster.rootObj.name + " do normal attack");

			caster.DoAttack(false);
		}
	}
}
